

<?php
    @header('Content-type:text/html;charset=utf-8');
    @include_once('conn.php');
    @include_once("noparams.php");

    $id = $_GET['id'];
    if(!$id){
        NoParamsErr();
    }

    $sql =  "delete from `grade` where id = $id" ;    // 删除一个 
    // $sql =  "delete from `grade` where id in ($id)" ;    // 可以同时删除多个

    $result = mysqli_query($conn,$sql);
    if(!$result){
        $obj = array();
        $obj['status'] = false;
        $obj['detail'] = "Sql 语句有问题";
        $obj['sql'] = $sql;
        exit(json_encode($obj));
    }

    // 删除

    $rows = mysqli_affected_rows($conn);  // sql操作 受影响的函数
    $obj = array();
    if($rows>0){
        $obj['status'] = true;
        $obj['detail'] = "删除成功";
    }else{
        $obj['status'] = false;
        $obj['detail'] = "删除失败,数据不存在";
    }

    echo json_encode($obj)
?>